﻿using Enyim.Caching;
using Ayatta.Contract;
using Web.Base.Extensions;
using Web.My.Models;
using System.Web.Mvc;
using Web.Base.Security;
using Ayatta.Contract.Domain;
using Ayatta.Contract.Component;

namespace Web.My.Controllers
{
    public class AuctionController : MyBaseController
    {
        public AuctionController(ILogService logService, IBaseService baseService, IExtraService extraService, IStoreService storeService, IOrderService orderService, IGameService gameService, IAuctionService auctionService, IPassportService passportService, IPaymentService paymentService, IMemcachedClient memcachedClient): base(logService, baseService, extraService, storeService, orderService, gameService, auctionService, passportService, paymentService, memcachedClient)
        {

        }

        public ActionResult Index(int page = 1, int size = 20)
        {
            var identity = User.Identity.Identity();
            var model = new AuctionControllerModel.Index();
            model.Orders = AuctionService.GetPagedAuctionOrder(page, size, identity.Id).ToPagedList(page, size);
            return View(model);
        }

        /// <summary>
        /// 晒图
        /// </summary>
        /// <param name="param">OrderItemId</param>
        /// <returns></returns>
        public ActionResult Share(string param)
        {
            var identity = User.Identity.Identity();
            var model = new AuctionControllerModel.Share();
            model.Auction = OrderService.GetOrderItem(param, identity.Id, false);
            return View(model);
        }

        /// <summary>
        /// 晒图
        /// </summary>
        /// <param name="param">拍品Id</param>
        /// <param name="message">感言</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Share(string param, string message)
        {
            var identity = User.Identity.Identity();
            var result = new SkResult<string>();
            var item = OrderService.GetOrderItem(param, identity.Id, false);
            if (item != null && item.Status == OrderStatus.Finished && item.AuctionId.HasValue)
            {

            }
            return Json(result);
        }
    }
}
